home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / h / lg2h.awk < prev    next >
Encoding:
AWK Script  |  1996-09-27  |  983 b   |  49 lines

  1. #{{{}}}
  2. #{{{  init defines
  3. BEGIN {
  4.   FS="\t"
  5.   doublequote=sprintf("%c",34)
  6.   type  ="#define LANGTYP "
  7.   data  ="#define LANGDATA "
  8.   first=1
  9. #  {{{  print auto-gen-mark
  10.   print("/* This file is generated autmoatically by awk -f lg2h.awk */\n/* containing the predefined fold language types */")
  11. #  }}}
  12. }
  13. #}}}
  14. $1!="#" {
  15. #  {{{  LANGTYP
  16.   type  =type "FC_" substr($1,2,length($1)-2) ","
  17. #  }}}
  18. #  {{{  LANGDATA
  19. #  {{{  id
  20.   id=$1
  21. #  }}}
  22. #  {{{  start
  23.   if (length($2)!=2) {
  24.      start_txt="(unsigned char*)" $2
  25.      start_lg ="sizeof("$2")-1"
  26.   } else {
  27.      start_txt="(unsigned char*)empty_text"
  28.      start_lg ="0"
  29.   }
  30. #  }}}
  31. #  {{{  end
  32.   if (length($3)!=2) {
  33.      end_txt="(unsigned char*)" $3
  34.      end_lg ="sizeof("$3")-1"
  35.   } else {
  36.      end_txt="(unsigned char*)empty_text"
  37.      end_lg ="0"
  38.   }
  39. #  }}}
  40.   data=sprintf("%s\\\n LG_DAT(%s,%s,%s,%s,%s),",data,id,start_txt,start_lg,end_txt,end_lg)
  41. #  }}}
  42.   first=0
  43. }
  44. #{{{  print defines
  45. END {
  46.   printf("%s\n%s\n",type,data)
  47. }
  48. #}}}
  49.